home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / TimeObjects.p < prev    next >
Text File  |  1996-05-01  |  16KB  |  421 lines

  1. {
  2.      File:        TimeObjects.p
  3.  
  4.      Contains:    International Time Interfaces.
  5.  
  6.      Version:    Technology:    System 8
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT TimeObjects;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __TIMEOBJECTS__}
  28. {$SETC __TIMEOBJECTS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC TimeObjectsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __CONDITIONALMACROS__}
  35. {$I ConditionalMacros.p}
  36. {$ENDC}
  37. {$IFC UNDEFINED __KERNEL__}
  38. {$I Kernel.p}
  39. {$ENDC}
  40. {$IFC UNDEFINED __LOCALEOBJECTS__}
  41. {$I LocaleObjects.p}
  42. {$ENDC}
  43. {$IFC UNDEFINED __OSUTILS__}
  44. {$I OSUtils.p}
  45. {$ENDC}
  46. {$IFC UNDEFINED __TEXTOBJECTS__}
  47. {$I TextObjects.p}
  48. {$ENDC}
  49. {$IFC UNDEFINED __TIMING__}
  50. {$I Timing.p}
  51. {$ENDC}
  52. {$IFC UNDEFINED __TYPES__}
  53. {$I Types.p}
  54. {$ENDC}
  55.  
  56. {$PUSH}
  57. {$ALIGN MAC68K}
  58. {$LibExport+}
  59.  
  60. {
  61.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  62.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  63.  ++                                                                                ++
  64.  ++                        Type definitions for Modern APIs                        ++
  65.  ++                                                                                ++
  66.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  68. }
  69. {$IFC FOR_SYSTEM8_PREEMPTIVE }
  70. {  Precision of TimeObject  }
  71.  
  72. TYPE
  73.     TimeObjectPrecision                    = UInt8;
  74.  
  75. CONST
  76.     kTONanosecondsPrecision        = $00;
  77.     kTOMicrosecondsPrecision    = $01;
  78.     kTOMillisecondsPrecision    = $02;
  79.     kTOSecondsPrecision            = $03;
  80.     kTOMinutesPrecision            = $04;
  81.     kTOHoursPrecision            = $05;
  82.     kTODaysPrecision            = $06;
  83.  
  84. {  Maximun Time Object Precision  }
  85.     kTOMaxPrecision                = $06;
  86.  
  87.  
  88. TYPE
  89.     TimeObjectNotificationRef            = UInt32;
  90.     MachineLocationRecordPtr = ^MachineLocationRecord;
  91.     MachineLocationRecord = RECORD
  92.         longitude:                Fixed;
  93.         latitude:                Fixed;
  94.         daylightSavingsDelta:    TimeObjectInterval;
  95.         utcDelta:                TimeObjectInterval;
  96.     END;
  97.  
  98.     ConstMachineLocationRecordPtr        = ^MachineLocationRecord;
  99.     UTCTimeRecordPtr = ^UTCTimeRecord;
  100.     UTCTimeRecord = RECORD
  101.         era:                    UInt16;                                    {  [0 = B.C.E., 1 = C.E. ] }
  102.         year:                    UInt16;                                    {  [0, 65535] }
  103.         month:                    UInt16;                                    {  [0,12] }
  104.         day:                    UInt16;                                    {  [0,32] }
  105.         hour:                    UInt16;                                    {  [0,23] }
  106.         minute:                    UInt16;                                    {  [0,60] }
  107.         seconds:                UInt16;                                    {  [0,60] }
  108.         milliseconds:            UInt16;                                    {  [0,1e3) }
  109.         microseconds:            UInt32;                                    {  [0,1e6) }
  110.         nanoseconds:            UInt32;                                    {  [0,1e9) }
  111.         precision:                SInt8;
  112.     END;
  113.  
  114.     ConstUTCTimeRecordPtr                = ^UTCTimeRecord;
  115.     UTCTimeIntervalRecordPtr = ^UTCTimeIntervalRecord;
  116.     UTCTimeIntervalRecord = RECORD
  117.         day:                    SInt32;
  118.         hour:                    SInt32;
  119.         minute:                    SInt32;
  120.         seconds:                SInt32;
  121.         milliseconds:            SInt32;
  122.         microseconds:            SInt32;
  123.         nanoseconds:            SInt32;
  124.         precision:                SInt8;
  125.     END;
  126.  
  127.     ConstUTCTimeIntervalRecordPtr        = ^UTCTimeIntervalRecord;
  128.     TimeObjectConversionType            = UInt32;
  129.  
  130. CONST
  131.     kUseRomanNumbers            = 0;
  132.     kUseNativeNumbers            = 1;
  133.  
  134.  
  135. TYPE
  136.     CalendarObjectRef                    = LocaleObjectRef;
  137.     TimeObjectFormatString                = TextObject;
  138. {  DateTimeFormat Types:  }
  139.     FormatStringRef                        = UInt32;
  140.  
  141. CONST
  142.     kPreferredDateTimeFormat    = 0;
  143.     kShortDateTimeFormat        = 1;
  144.     kLongDateTimeFormat            = 2;
  145.     kShortTimeFormat            = 3;
  146.     kLongTimeFormat                = 4;
  147.  
  148. {$ENDC}
  149. {
  150.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  151.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  152.  ++                                                                                ++
  153.  ++                        Type definitions for Legacy APIs                        ++
  154.  ++                                                                                ++
  155.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  156.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  157. }
  158. {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED }
  159. {
  160.  
  161.     Here are the current routine names and the translations to the older forms.
  162.     Please use the newer forms in all new code and migrate the older names out of existing
  163.     code as maintainance permits.
  164.     
  165.     New Name                    Old Name(s)
  166.     
  167.     DateString                    IUDatePString IUDateString 
  168.     InitDateCache
  169.     LongDateString                IULDateString
  170.     LongTimeString                IULTimeString
  171.     StringToDate                String2Date
  172.     StringToTime                                
  173.     TimeString                    IUTimeString IUTimePString
  174. }
  175.  
  176. CONST
  177.     shortDate                    = 0;
  178.     longDate                    = 1;
  179.     abbrevDate                    = 2;
  180.  
  181.  
  182. TYPE
  183.     DateForm                            = SInt8;
  184.  
  185. CONST
  186.                                                                 {  StringToDate status values  }
  187.     fatalDateTime                = $8000;                        {  StringToDate and String2Time mask to a fatal error  }
  188.     longDateFound                = 1;                            {  StringToDate mask to long date found  }
  189.     leftOverChars                = 2;                            {  StringToDate & Time mask to warn of left over characters  }
  190.     sepNotIntlSep                = 4;                            {  StringToDate & Time mask to warn of non-standard separators  }
  191.     fieldOrderNotIntl            = 8;                            {  StringToDate & Time mask to warn of non-standard field order  }
  192.     extraneousStrings            = 16;                            {  StringToDate & Time mask to warn of unparsable strings in text  }
  193.     tooManySeps                    = 32;                            {  StringToDate & Time mask to warn of too many separators  }
  194.     sepNotConsistent            = 64;                            {  StringToDate & Time mask to warn of inconsistent separators  }
  195.     tokenErr                    = $8100;                        {  StringToDate & Time mask for 'tokenizer err encountered'  }
  196.     cantReadUtilities            = $8200;
  197.     dateTimeNotFound            = $8400;
  198.     dateTimeInvalid                = $8800;
  199.  
  200.  
  201. TYPE
  202.     StringToDateStatus                    = INTEGER;
  203.     String2DateStatus                    = INTEGER;
  204.     DateCacheRecordPtr = ^DateCacheRecord;
  205.     DateCacheRecord = PACKED RECORD
  206.         hidden:                    ARRAY [0..255] OF INTEGER;                {  only for temporary use  }
  207.     END;
  208.  
  209.     DateCachePtr                        = ^DateCacheRecord;
  210. {$ENDC}
  211. {
  212.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  213.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  214.  ++                                                                                ++
  215.  ++                                Modern API Definitions                            ++
  216.  ++                                                                                ++
  217.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  218.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  219. }
  220. {$IFC FOR_SYSTEM8_PREEMPTIVE }
  221. {
  222.  *********************************************************
  223.  *
  224.  * TimeObject Constructors
  225.  *
  226.  *********************************************************
  227. }
  228. FUNCTION CreateTimeObject(timeObject: TimeObjectPtr; utcTime: ConstUTCTimeRecordPtr): OSStatus; C;
  229. FUNCTION CreateTimeObjectInterval(timeObjectInterval: TimeObjectIntervalPtr; utcTimeInterval: ConstUTCTimeIntervalRecordPtr): OSStatus; C;
  230. {
  231.  *********************************************************
  232.  *
  233.  * Getter and Setter Functions for TimeObjects
  234.  *
  235.  *********************************************************
  236. }
  237. FUNCTION GetCurrentTime(timeObj: TimeObjectPtr): OSStatus; C;
  238. FUNCTION SetCurrentTime(timeObj: ConstTimeObjectPtr): OSStatus; C;
  239. {
  240.  *********************************************************
  241.  *
  242.  * Getter and Setter Functions for Machine Location
  243.  *
  244.  *********************************************************
  245. }
  246. FUNCTION GetMachineLocation(machineLocation: MachineLocationRecordPtr): OSStatus; C;
  247. FUNCTION SetMachineLocation(machineLocation: ConstMachineLocationRecordPtr): OSStatus; C;
  248. {
  249.  *********************************************************
  250.  *
  251.  * Getter and Setter Functions for TimeObjects Precision
  252.  *
  253.  *********************************************************
  254. }
  255. FUNCTION GetTimeObjectPrecision(timeObj: ConstTimeObjectPtr; VAR precision: TimeObjectPrecision): OSStatus; C;
  256. FUNCTION SetTimeObjectPrecision(timeObj: TimeObjectPtr; precision: ByteParameter): OSStatus; C;
  257. FUNCTION GetTimeObjectIntervalPrecision(timeObj: ConstTimeObjectIntervalPtr; VAR precision: TimeObjectPrecision): OSStatus; C;
  258. FUNCTION SetTimeObjectIntervalPrecision(timeObj: TimeObjectIntervalPtr; precision: ByteParameter): OSStatus; C;
  259. {
  260.  *********************************************************
  261.  *
  262.  * Timers
  263.  *
  264.  *********************************************************
  265. }
  266. FUNCTION CreateTimeObjectNotifier(timeObject: ConstTimeObjectPtr; VAR notifier: KernelNotification; VAR notificationRef: TimeObjectNotificationRef): OSStatus; C;
  267. FUNCTION CancelTimeObjectNotifier(notificationRef: TimeObjectNotificationRef): OSStatus; C;
  268. {
  269.  *********************************************************
  270.  *
  271.  * Manipulation and Comparison functions for TimeObjects
  272.  *
  273.  *********************************************************
  274. }
  275. FUNCTION AddToFixedTimeObject(fixedTimeObj: ConstTimeObjectPtr; offsetTimeObj: ConstTimeObjectIntervalPtr; result: TimeObjectPtr): OSStatus; C;
  276. FUNCTION AddTimeObjectIntervals(timeObj1: ConstTimeObjectIntervalPtr; timeObj2: ConstTimeObjectIntervalPtr; result: TimeObjectIntervalPtr): OSStatus; C;
  277. FUNCTION SubtractFromFixedTimeObject(fixedTimeObj: ConstTimeObjectPtr; offsetTimeObj: ConstTimeObjectIntervalPtr; result: TimeObjectPtr): OSStatus; C;
  278. FUNCTION SubtractTimeObjectIntervals(timeObj1: ConstTimeObjectIntervalPtr; timeObj2: ConstTimeObjectIntervalPtr; result: TimeObjectIntervalPtr): OSStatus; C;
  279. FUNCTION SubtractFixedTimeObjects(timeObj1: ConstTimeObjectPtr; timeObj2: ConstTimeObjectPtr; result: TimeObjectIntervalPtr): OSStatus; C;
  280. FUNCTION CompareFixedTimeObjects(timeObj1: ConstTimeObjectPtr; timeObj2: ConstTimeObjectPtr; precision: ConstTimeObjectIntervalPtr; VAR result: SInt32): OSStatus; C;
  281. FUNCTION CompareTimeObjectIntervals(timeObj1: ConstTimeObjectIntervalPtr; timeObj2: ConstTimeObjectIntervalPtr; precision: ConstTimeObjectIntervalPtr; VAR result: SInt32): OSStatus; C;
  282. {
  283.  *********************************************************
  284.  *
  285.  * TimeObjects to Seconds from 1/1/04 conversion functions
  286.  *
  287.  *********************************************************
  288. }
  289. FUNCTION ConvertSecondsToTimeObject(seconds: UInt32; convertedTimeObj: TimeObjectPtr): OSStatus; C;
  290. FUNCTION ConvertTimeObjectToSeconds(timeObj: ConstTimeObjectPtr; VAR seconds: UInt32): OSStatus; C;
  291. FUNCTION ConvertLongDateTimeToTimeObject(VAR longDateTime: LongDateTime; convertedTimeObj: TimeObjectPtr): OSStatus; C;
  292. FUNCTION ConvertTimeObjectToLongDateTime(timeObj: ConstTimeObjectPtr; VAR longDateTime: LongDateTime): OSStatus; C;
  293. {
  294.  *********************************************************
  295.  *
  296.  * TimeObjectIntervals to Nanosecond conversion functions
  297.  *
  298.  *********************************************************
  299. }
  300. FUNCTION ConvertTimeObjectIntervalToNanoseconds(source: ConstTimeObjectIntervalPtr; VAR result: Nanoseconds): OSStatus; C;
  301. FUNCTION ConvertNanosecondsToTimeObjectInterval(VAR source: Nanoseconds; result: TimeObjectIntervalPtr): OSStatus; C;
  302. {
  303.  *********************************************************
  304.  *
  305.  * Internet Time/Mail Conversion Routines
  306.  *
  307.  *********************************************************
  308. }
  309. FUNCTION ConvertTimeObjectToInternetMailTime(source: ConstTimeObjectPtr; result: TextObject): OSStatus; C;
  310. FUNCTION ConvertInternetMailTimeToTimeObject(source: TextObject; result: TimeObjectPtr): OSStatus; C;
  311. FUNCTION ConvertTimeObjectToInternetTime(source: ConstTimeObjectPtr; VAR result: UInt32): OSStatus; C;
  312. FUNCTION ConvertInternetTimeToTimeObject(internetTime: UInt32; result: TimeObjectPtr): OSStatus; C;
  313. {
  314.  *********************************************************
  315.  *
  316.  * Calendar Routines
  317.  *
  318.  *********************************************************
  319. }
  320. FUNCTION GetDefaultCalendar(theLocale: LocaleRef; VAR theCalendar: CalendarObjectRef): OSStatus; C;
  321. FUNCTION GetDefaultSystemCalendar(VAR theCalendar: CalendarObjectRef): OSStatus; C;
  322. {
  323.  *********************************************************
  324.  *
  325.  * Text Conversion Routines
  326.  *
  327.  *********************************************************
  328. }
  329. FUNCTION ConvertTimeObjectToDateString(timeObj: ConstTimeObjectPtr; theCalendar: CalendarObjectRef; textObj: TextObject; format: TimeObjectFormatString; formatSelector: FormatStringRef; conversionSelector: TimeObjectConversionType): OSStatus; C;
  330. FUNCTION ConvertTimeObjectToTimeString(timeObjectInterval: ConstTimeObjectIntervalPtr; theCalendar: CalendarObjectRef; textObj: TextObject; format: TimeObjectFormatString; formatSelector: FormatStringRef; conversionSelector: TimeObjectConversionType): OSStatus; C;
  331. FUNCTION ConvertDateStringToTimeObject(timeObj: TimeObjectPtr; theCalendar: CalendarObjectRef; textObj: TextObject; conversionSelector: TimeObjectConversionType): OSStatus; C;
  332. FUNCTION ConvertTimeStringToTimeObject(timeObjectInterval: TimeObjectIntervalPtr; theCalendar: CalendarObjectRef; textObj: TextObject; conversionSelector: TimeObjectConversionType): OSStatus; C;
  333. {$ENDC}
  334. {
  335.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  336.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  337.  ++                                                                                ++
  338.  ++                                Legacy API Definitions                            ++
  339.  ++                                                                                ++
  340.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  341.  +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  342. }
  343. {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED }
  344. {
  345.  **************************************************************************************
  346.  *
  347.  * The following functions are new names that work on 68k and PowerPC
  348.  *
  349.  **************************************************************************************
  350. }
  351. FUNCTION InitDateCache(theCache: DateCachePtr): OSErr;
  352.     {$IFC NOT GENERATINGCFM}
  353.     INLINE $2F3C, $8204, $FFF8, $A8B5;
  354.     {$ENDC}
  355. FUNCTION StringToDate(textPtr: Ptr; textLen: LONGINT; theCache: DateCachePtr; VAR lengthUsed: LONGINT; VAR dateTime: LongDateRec): StringToDateStatus;
  356.     {$IFC NOT GENERATINGCFM}
  357.     INLINE $2F3C, $8214, $FFF6, $A8B5;
  358.     {$ENDC}
  359. FUNCTION StringToTime(textPtr: Ptr; textLen: LONGINT; theCache: DateCachePtr; VAR lengthUsed: LONGINT; VAR dateTime: LongDateRec): StringToDateStatus;
  360.     {$IFC NOT GENERATINGCFM}
  361.     INLINE $2F3C, $8214, $FFF4, $A8B5;
  362.     {$ENDC}
  363. PROCEDURE IUDateString(dateTime: LONGINT; longFlag: DateForm; VAR result: Str255);
  364.     {$IFC NOT GENERATINGCFM}
  365.     INLINE $4267, $A9ED;
  366.     {$ENDC}
  367. PROCEDURE IUTimeString(dateTime: LONGINT; wantSeconds: BOOLEAN; VAR result: Str255);
  368.     {$IFC NOT GENERATINGCFM}
  369.     INLINE $3F3C, $0002, $A9ED;
  370.     {$ENDC}
  371. PROCEDURE IUDatePString(dateTime: LONGINT; longFlag: DateForm; VAR result: Str255; intlHandle: Handle);
  372.     {$IFC NOT GENERATINGCFM}
  373.     INLINE $3F3C, $000E, $A9ED;
  374.     {$ENDC}
  375. PROCEDURE IUTimePString(dateTime: LONGINT; wantSeconds: BOOLEAN; VAR result: Str255; intlHandle: Handle);
  376.     {$IFC NOT GENERATINGCFM}
  377.     INLINE $3F3C, $0010, $A9ED;
  378.     {$ENDC}
  379. PROCEDURE IULDateString(VAR dateTime: LongDateTime; longFlag: DateForm; VAR result: Str255; intlHandle: Handle);
  380.     {$IFC NOT GENERATINGCFM}
  381.     INLINE $3F3C, $0014, $A9ED;
  382.     {$ENDC}
  383. PROCEDURE IULTimeString(VAR dateTime: LongDateTime; wantSeconds: BOOLEAN; VAR result: Str255; intlHandle: Handle);
  384.     {$IFC NOT GENERATINGCFM}
  385.     INLINE $3F3C, $0016, $A9ED;
  386.     {$ENDC}
  387. {
  388.  **************************************************************************************
  389.  *
  390.  * The following provide direct function prototypes for new names for 68k
  391.  *
  392.  **************************************************************************************
  393. }
  394. PROCEDURE DateString(dateTime: LONGINT; longFlag: DateForm; VAR result: Str255; intlHandle: Handle);
  395.     {$IFC NOT GENERATINGCFM}
  396.     INLINE $3F3C, $000E, $A9ED;
  397.     {$ENDC}
  398. PROCEDURE TimeString(dateTime: LONGINT; wantSeconds: BOOLEAN; VAR result: Str255; intlHandle: Handle);
  399.     {$IFC NOT GENERATINGCFM}
  400.     INLINE $3F3C, $0010, $A9ED;
  401.     {$ENDC}
  402. PROCEDURE LongDateString(VAR dateTime: LongDateTime; longFlag: DateForm; VAR result: Str255; intlHandle: Handle);
  403.     {$IFC NOT GENERATINGCFM}
  404.     INLINE $3F3C, $0014, $A9ED;
  405.     {$ENDC}
  406. PROCEDURE LongTimeString(VAR dateTime: LongDateTime; wantSeconds: BOOLEAN; VAR result: Str255; intlHandle: Handle);
  407.     {$IFC NOT GENERATINGCFM}
  408.     INLINE $3F3C, $0016, $A9ED;
  409.     {$ENDC}
  410. {$ENDC}
  411. {$ALIGN RESET}
  412. {$POP}
  413.  
  414. {$SETC UsingIncludes := TimeObjectsIncludes}
  415.  
  416. {$ENDC} {__TIMEOBJECTS__}
  417.  
  418. {$IFC NOT UsingIncludes}
  419.  END.
  420. {$ENDC}
  421.